import org.newdawn.slick.Animation;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
import org.newdawn.slick.geom.Vector2f;

import it.randomtower.engine.entity.Entity;


public class GUICharacter extends Entity {
	int playerX;
	int playerY;
	Animation player;
	boolean selected;
	//int hight;
	//int width;
	//All entities have a Height and Depth
	Color highlighted = new Color(1.0f,1.0f,.5f);
	
	public void setSelected(boolean x){
		selected = x;
	}

	public GUICharacter(int x, int y) throws SlickException {
		super(x, y);
		playerX = x;
		playerY = y;
		System.out.println("X:Y, "+ playerX + ":"+ playerY);
		SpriteSheet sheet = new SpriteSheet("images/karbonator.png", 32, 32);
		this.height = 32;
		this.width = 32;
		player = new Animation();
		player.setAutoUpdate(true);
		for (int frame = 0; frame < 3; frame++) {
			player.addFrame(sheet.getSprite(frame, 0), 150);
		}
		
	}
	
	public void setHeight(int x){
		height = x;
	}
	
	public int getHeight(int x){
		return(height);
	}
	
	public void setWidth(int x){
		width = x;
	}
	
	public int getWidth(int x){
		return(width);
	}

	public boolean isPlayerAtLocation(int mouseX, int mouseY) {
		/*System.out.println("Player width:height:  " + this.width + ":" + this.height);
		System.out.println(mouseX < this.playerX || mouseY < this.playerY || mouseX > this.playerX + this.width
				|| mouseY > this.playerY + this.height);
		System.out.println(mouseX > this.playerX && mouseX < this.playerX + this.width);
		//System.out.println(this.playerY + ", " + this.playerX + ":" + mouseY +", " + mouseX);
		*/
		return(mouseX > this.playerX && mouseX < this.playerX + this.width && mouseY > this.playerY && mouseY < this.playerY + this.height);
		//return(mouseX < this.playerX || mouseY < this.playerY || mouseX > this.playerX + this.width
		//		|| mouseY > this.playerY + this.height);
	}
	
	public void movePlayer(int x, int y){
		System.out.println("Moving Player");
		playerX = x;
		playerY = y;
		setPosition(new Vector2f(playerX, playerY));
	}
	
	public void render(GameContainer container, Graphics g) {
		try {
			super.render(container, g);
		} catch (SlickException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if(selected)
			g.drawAnimation(player, playerX, playerY, highlighted);
		else
			g.drawAnimation(player, playerX, playerY);
		
	}

}
